package com.ruoyi.web.controller.monitor;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysDatabaseGpx;
import com.ruoyi.system.service.ISysDatabaseGpxService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 数据库信息Controller
 * 
 * @author ruoyi
 * @date 2025-10-31
 */
@RestController
@RequestMapping("/system/gpx")
public class SysDatabaseGpxController extends BaseController
{
    @Autowired
    private ISysDatabaseGpxService sysDatabaseGpxService;

    /**
     * 查询数据库信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:gpx:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysDatabaseGpx sysDatabaseGpx)
    {
        startPage();
        List<SysDatabaseGpx> list = sysDatabaseGpxService.selectSysDatabaseGpxList(sysDatabaseGpx);
        return getDataTable(list);
    }

    /**
     * 导出数据库信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:gpx:export')")
    @Log(title = "数据库信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysDatabaseGpx sysDatabaseGpx)
    {
        List<SysDatabaseGpx> list = sysDatabaseGpxService.selectSysDatabaseGpxList(sysDatabaseGpx);
        ExcelUtil<SysDatabaseGpx> util = new ExcelUtil<SysDatabaseGpx>(SysDatabaseGpx.class);
        util.exportExcel(response, list, "数据库信息数据");
    }

    /**
     * 获取数据库信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:gpx:query')")
    @GetMapping(value = "/{databaseId}")
    public AjaxResult getInfo(@PathVariable("databaseId") Long databaseId)
    {
        return success(sysDatabaseGpxService.selectSysDatabaseGpxByDatabaseId(databaseId));
    }

    /**
     * 新增数据库信息
     */
    @PreAuthorize("@ss.hasPermi('system:gpx:add')")
    @Log(title = "数据库信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysDatabaseGpx sysDatabaseGpx)
    {
        return toAjax(sysDatabaseGpxService.insertSysDatabaseGpx(sysDatabaseGpx));
    }

    /**
     * 修改数据库信息
     */
    @PreAuthorize("@ss.hasPermi('system:gpx:edit')")
    @Log(title = "数据库信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysDatabaseGpx sysDatabaseGpx)
    {
        return toAjax(sysDatabaseGpxService.updateSysDatabaseGpx(sysDatabaseGpx));
    }

    /**
     * 删除数据库信息
     */
    @PreAuthorize("@ss.hasPermi('system:gpx:remove')")
    @Log(title = "数据库信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{databaseIds}")
    public AjaxResult remove(@PathVariable Long[] databaseIds)
    {
        return toAjax(sysDatabaseGpxService.deleteSysDatabaseGpxByDatabaseIds(databaseIds));
    }
}
